package com.design_pattern._01_create._02_builder;

public class Person {
    String name;
    int age;
    int height;
    String CityName;
    String CityLatitude;
    String CityLongitude;

    private Person() { // 构造方法私有，进行权限控制
    }

    public static PersonBuilder getBuilder(){
        return new Person.PersonBuilder();
    }

    public static class PersonBuilder {
        private Person person = new Person();

        /**
         * 这里可以填写默认值
         */
        public PersonBuilder buildBasic(String name,
                                        int age,
                                        int height) {
            person.name = name;
            person.age = age;
            person.height = height;
            return this;
        }

        public PersonBuilder buildLoc(String CityName,
                                      String CityLatitude,
                                      String CityLongitude) {
            person.CityName = CityName;
            person.CityLatitude = CityLatitude;
            person.CityLongitude = CityLongitude;
            return this;
        }

        public Person build() {
            return person;
        }
    }

}

